#include<bits/stdc++.h>
#define int long long
using namespace std;
inline int read(){
	int x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
	while('0'<=ch&&ch<='9')x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int Maxn=32768;
int n;
struct edge{
	int u,v,w;
}e[555];
int cnt1;
int vis[20][20];
int cnt;
namespace sub3{
	inline void solve(){
		cnt--;
		e[++cnt1]={1,2,0};
		for(int i=0;i<cnt;i++)
			e[++cnt1]={i+2,i+3,(1<<i)},e[++cnt1]={i+2,i+3,0};
		e[++cnt1]={cnt+2,114,0};e[++cnt1]={cnt+2,114,(1<<cnt)};
		e[++cnt1]={1,114,n};
		printf("%d %d\n",cnt+3,cnt1);
		for(int i=1;i<=cnt1;i++){
			printf("%d %d %d\n",e[i].u,e[i].v,e[i].w);
		}
	}
}
signed main(){
//	ios::sync_with_stdio(0);
//	cin.tie(0);cout.tie(0);
	freopen("road.in","r",stdin);
	freopen("road.out","w",stdout);
	n=read();
	for(int x=n;x>1;x/=2)cnt++;
	if((1<<cnt)==n)sub3::solve(),exit(0);
	for(int i=0;i<=cnt;i++)e[++cnt1]={1,i+2,0};
	e[++cnt1]={1,114,0};
	for(int s=1;s<=n;s++){
		vector<int>v;
		for(int i=0;i<=cnt;i++)
			if(s&(1<<i))v.push_back(i);
		for(int i=0;i<v.size()-1;i++){
			if(!vis[v[i]+2][v[i+1]+2])e[++cnt1]={v[i]+2,v[i+1]+2,(1<<v[i])};
			vis[v[i]+2][v[i+1]+2]=1;
		}
		if(v.size()==1)e[++cnt1]={v[0]+2,114,(1<<v[0])};
	}
	printf("%d %d\n",cnt+3,cnt1);
	for(int i=1;i<=cnt1;i++){
		printf("%d %d %d\n",e[i].u,e[i].v,e[i].w);
	}
	return 0;
}
/*
checker.exe road.in road.out road1.in 10 score.txt report.txt
*/
